package audio;

import java.io.File;
import java.io.IOException;

import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;

import utils.StackTracePrinter;

public class GenericSound extends SpotSound {



	public GenericSound(String filePath) throws IOException, UnsupportedAudioFileException, LineUnavailableException {

		soundFile = new File (filePath);
		prepareAudioStream();

	}

	

	@Override
	public void stopSound() {
		clip.stop();
	}



	@Override
	public void playSound() {
		new Thread (new Runnable() {
			
			@Override
			public void run() {
				try {
					clip.open(audioInputStream);
				} catch (LineUnavailableException e) {
					StackTracePrinter.print(e);
					return;
				} catch (IOException e) {
					StackTracePrinter.print(e);
					return;
				}
				clip.start();
			}
		}).start();
		
	}


}
